



import javax.sql.DataSource;

import com.jfinal.kit.PathKit;
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
import com.jfinal.plugin.activerecord.generator.Generator;
import com.jfinal.plugin.druid.DruidPlugin;

public class GeneratorModel {

	public static DataSource getDataSource() {
		String url = "jdbc:mysql://119.23.129.7:3306/wallet";
		String userName = "payuser";
		String password = "payuser123";
		DruidPlugin adminBD = new DruidPlugin(url,userName,password);
		adminBD.start();
		return adminBD.getDataSource();
	}

	public static void main(String[] args) {
		// base model 所使用的包名
		String baseModelPackageName = "net.gz01.wallet.web.model.base";
		// base model 文件保存路径
		String baseModelOutputDir = PathKit.getWebRootPath() + "/src/main/java/net/gz01/wallet/web/model/base";



		// 创建生成器
		Generator gernerator = new Generator(getDataSource(), baseModelPackageName, baseModelOutputDir);
		// 设置数据库方言
		gernerator.setDialect(new MysqlDialect());
		// 添加不需要生成的表名
		gernerator.addExcludedTable("seq_test","sequence","QRTZ_BLOB_TRIGGERS","QRTZ_CALENDARS","QRTZ_CRON_TRIGGERS","QRTZ_FIRED_TRIGGERS",
				"QRTZ_JOB_DETAILS","QRTZ_LOCKS","QRTZ_PAUSED_TRIGGER_GRPS","QRTZ_SCHEDULER_STATE","QRTZ_SIMPLE_TRIGGERS","QRTZ_SIMPROP_TRIGGERS","QRTZ_TRIGGERS");
		// 设置是否在 Model 中生成 dao 对象
		gernerator.setGenerateDaoInModel(true);
		// 设置是否生成字典文件
		gernerator.setGenerateDataDictionary(false);
		// 设置需要被移除的表名前缀用于生成modelName。例如表名 "osc_user"，移除前缀 "osc_"后生成的model名为 "User"而非 OscUser
		gernerator.setRemovedTableNamePrefixes("t_","sm_","ta_","tr_","tl_","bd_","QRTZ_","c_");
		// 生成
		gernerator.generate();
	}

}
